package com.hoongs.v1.vo;

import com.hoongs.v1.entity.Address;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class AddressVo {

    private String id;

    private String gender = "0"; // 性别信息 1:男 2:女 0:保密

    @NotBlank(message = "请输入收货人姓名")
    private String name;

    @NotBlank(message = "请输入用户联系电话")
    private String mobile;

    @NotBlank(message = "请输入用户配送地址")
    private String address;

    @NotBlank(message = "请输入用户详细配送地址")
    private String addressDetail;

    private String tag;         // 地址标签

    private String tagDictValue;

    private String isDefault = "0";

    private String userId;

    public static AddressVo voFromDao(Address address) {
        AddressVo addressVo = new AddressVo();
        addressVo.setId(address.getId());
        addressVo.setGender(address.getGender());
        addressVo.setName(address.getName());
        addressVo.setMobile(address.getMobile());
        addressVo.setAddress(address.getAddress());
        addressVo.setAddressDetail(address.getAddressDetail());
        addressVo.setTag(address.getTag());
        addressVo.setTagDictValue(address.getTagDictValue());
        addressVo.setUserId(address.getUserId());
        return addressVo;
    }

    public static Address voToDao(AddressVo addressVo) {
        Address addressDao = new Address();
        addressDao.setId(addressVo.getId());
        addressDao.setGender(addressVo.getGender());
        addressDao.setName(addressVo.getName());
        addressDao.setMobile(addressVo.getMobile());
        addressDao.setAddress(addressVo.getAddress());
        addressDao.setAddressDetail(addressVo.getAddressDetail());
        addressDao.setTag(addressVo.getTag());
        addressDao.setTagDictValue(addressVo.getTagDictValue());
        addressDao.setUserId(addressVo.getUserId());
        return addressDao;
    }
}